Skip to content

Conversation

@Zaimwa9
Copy link
Contributor

@Zaimwa9 Zaimwa9 commented Oct 28, 2025

Contributes to #81

In this 3/3 PR related to evaluation context in local evaluation mode

In this PR:

  • SDK layer uses the new engine in the client local evaluation
  • Implementation of a proper JSONPath library
  • Clean-up deprecated code and methods

@Zaimwa9 Zaimwa9 requested a review from a team as a code owner October 28, 2025 15:03
@Zaimwa9 Zaimwa9 requested review from khvn26 and removed request for a team October 28, 2025 15:03
@Zaimwa9 Zaimwa9 marked this pull request as draft October 28, 2025 15:03
@Zaimwa9 Zaimwa9 changed the title feat: sdk consumes context engine [draft] feat: sdk consumes context engine Oct 29, 2025
@Zaimwa9 Zaimwa9 marked this pull request as ready for review October 29, 2025 09:41
Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left three comments.

Comment on lines +106 to +111
# Floats/doubles are not supported by the engine due to ambiguous serialization across supported platforms. (segments/models_spec.rb)
return false unless trait_value.is_a?(String) || trait_value.is_a?(Integer)

if @value.is_a?(Array)
return @value.include?(trait_value.to_s)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Flagsmith/engine-test-data#38, we only skip booleans now:

Suggested change
# Floats/doubles are not supported by the engine due to ambiguous serialization across supported platforms. (segments/models_spec.rb)
return false unless trait_value.is_a?(String) || trait_value.is_a?(Integer)
if @value.is_a?(Array)
return @value.include?(trait_value.to_s)
end
(segments/models_spec.rb)
return false unless ![true, false].include? trait_value
if @value.is_a?(Array)
return @value.include?(trait_value.to_s)
end

"This indicates a bug in the SDK, please report it."
end

acc[normalize_key(flag_result[:name])] = Flagsmith::Flags::Flag.new(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to normalise the feature name?

# Flags engine methods
# NOTE: This class is kept for backwards compatibility but no longer contains
# the old model-based evaluation methods. Use the context-based evaluation
# via Flagsmith::Engine::Evaluation::Core.get_evaluation_result instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're major-versioning anyway, can we either remove the class altogether, add Flagsmith::Engine::get_evaluation_result interface? I don't see how an empty Engine class helps to maintain backwards compatibility here?

# frozen_string_literal: true

require 'json'
require 'jsonpath'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought JSONPath part was moved to #88? Should this PR get rebased?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants